﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace FaWorks.WebSite
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "StudyMap",
                url: "Study/{view}",
                defaults: new { controller = "Study", action = "RenderView", view = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "CodeMap",
                url: "Code/{type}/{view}",
                defaults: new { controller = "Code", action = "RenderView", type = UrlParameter.Optional, view = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "ManageMap",
                url: "Manage/{controller}/{action}/{id}",
                defaults: new { controller = "Manage", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "FaWorks.WebSite.Controllers.Manage" }
            );

            #region Model
            routes.MapRoute(
                name: "ModelsMap",
                url: "Models/{typeName}",
                defaults: new { controller = "Models", action = "GetModel" },
                namespaces: new[] { "FaWorks.WebSite.Controllers.Model" }
            );
            routes.MapRoute(
                name: "ModelMap",
                url: "Model/{controller}/{action}/{id}",
                defaults: new { controller = "Model", action = "CURD", id = UrlParameter.Optional },
                namespaces: new[] { "FaWorks.WebSite.Controllers.Model" }
            );
            #endregion

            routes.MapRoute(
                name: "ScriptMap",
                url: "Script/Model/{type}",
                defaults: new { controller = "Script", action = "RenderModel" }
            );

            routes.MapRoute(
                name: "KnowledgeMap",
                url: "Knowledge/{*something}",
                defaults: new { controller = "Knowledge", action = "Index", something = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "FaWorks.WebSite.Controllers" }
            );
        }
    }
}